#ifndef CLIENT_H
#define CLIENT_H
#include "config.h"
#include "continue.h"
#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>

namespace cget {

using boost::asio::ip::tcp;

class Client;
typedef boost::shared_ptr<Client> client_ptr;

class Client {
public:
	Client(Config& c) : conf(c),sock(ios) { }
	virtual ~Client() { cout << "~Client()" << endl; }

	void connect();
	void run();
	virtual size_t getFileSize() = 0;
	virtual void thread_func(int from,int to) = 0;

	static client_ptr getClient(Config& c);

protected:
	Config& conf;
	boost::asio::io_service ios;
	tcp::socket sock;
	continue_ptr con_ptr;
}; //class Client

class HttpClient : public Client {
public:
	HttpClient(Config& c) : Client(c) { }
	~HttpClient() { cout << "~HttpClient()" << endl; }

	virtual size_t getFileSize();
	virtual void thread_func(int from,int to);

protected:

}; //class HttpClient

} //namespace cget

#endif

